package com.link.play.fit.ai.utils

import com.link.play.fit.ai.ext.d
import kotlin.math.abs

object GoalUtils {
    /**
     * 判断较小值是否不足较大值的5%
     * @return true 表示比例低于5%，false 表示不满足或无法计算
     */
    fun isRatioBelowFivePercent(min: Int, max: Int, percentage: Int): Boolean {
        if (min <= 0) return false
        // 计算较小值占较大值的百分比
        val ratio = (min.toDouble() / max.toDouble()) * 100
        return ratio < percentage
    }

    /**
     * 判断是否超过 百分比percentage
     */
    fun isOverGoal(min: Int, max: Int, percentage: Int): Boolean {
        if (min <= 0) return false
        // 计算较小值占较大值的百分比
        val ratio = (min.toDouble() / max.toDouble()) * 100
        return ratio > percentage
    }
}